package cn.cyh.exception;

import java.util.*;

/**
 * Created by Charlie on 2018/3/19.
 */
public class LambdaTest {

    public static void main(String[] args) {
        List<String> list = Arrays.asList("Lambdas", "Default Method", "Stream API", "Date and Time API");
        list.stream().filter(myString -> myString.contains("Lambdas")).forEach(System.out::println);

//        List<String> names = new ArrayList<>();
//        names.add("TaoBao");
//        names.add("ZhiFuBao");
//        System.out.println(names.stream().map(name -> name.charAt(0)).collect(Collectors.toList()));

        Map<String, List<String>> result = new HashMap<>();

        for (String article : list) {
            if (result.containsKey(article)) {
                result.get(article).add(article);
            } else {
                ArrayList<String> articles = new ArrayList<>();
                articles.add(article);
                result.put(article, articles);
            }
        }

    }

//    for(String myString: list) {
//        if(myString.contains("Lambdas")) {
//            System.out.println(myString);
//        }
//    }
}
